<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 통계 컨트롤러
 */
class Statistic extends CI_Controller {
	
	var $data = array();
	
	function __construct() {
		parent::__construct();
		
		$this->load->model('statistic/Payment_model', 'model');
		$this->load->helper(array('pagenavi'));
	}
	
	// Default
	function index() {
		
	}
	
	/**
	 * 결제 내역 리스트
	 */
	function payment_list() {
		log_message('debug', "@@@@ Statistic::payment_list()");
		
		$ptype        = $this->input->get('ptype', TRUE);
		$user_id      = $this->input->get('user_id', TRUE);
		$user_name    = $this->input->get('user_name', TRUE);
		$start_dt     = $this->input->get('start_dt', TRUE);
		$end_dt       = $this->input->get('end_dt', TRUE);
		$page         = $this->input->get('page', TRUE);

		$ptype        = isset($ptype) ? $ptype : '';
		$user_id      = isset($user_id) ? $user_id : '';
		$user_name    = isset($user_name) ? $user_name : '';
		$start_dt     = isset($start_dt) ? $start_dt : '';
		$end_dt       = isset($end_dt) ? $end_dt : '';
		$current_page = empty($page) ? 1 : $page;

		$page_size  = LIST_PAGE_SIZE;	// 한 페이지에 보여줄 글 수
		$block_size = LIST_BLOCK_SIZE;	// 네비영역의 한 블록에 보여줄 페이지 수

		$total_cnt    = $this->model->get_payment_history_total_count($ptype, $user_id, $user_name, $start_dt, $end_dt);	// 총 글 수
		$total_amount = $this->model->get_payment_history_total_amount($ptype, $user_id, $user_name, $start_dt, $end_dt);	// 총 결제액
		
		$this->data['list'] = $this->model->select_payment_history_list($ptype, $user_id, $user_name, $start_dt, $end_dt, $current_page, $page_size);
		$this->data['total_cnt'] = $total_cnt;
		$this->data['total_amount'] = $total_amount;
		$this->data['navi'] = page_navigation($current_page, $total_cnt, $page_size, $block_size);
		
		$ptype_name = array(
				  'package'=>'VIP회원권'
				, 'cash'   =>'캐쉬충전'
				, 'ticket' =>'개별이용권'
			);
			
		foreach ($this->data['list'] as &$item) {
			$item['ptype_name'] = $ptype_name[$item['ptype']];
		}
		
		$this->load->view('statistic/payment_list_v', $this->data);
	}

	/**
	 * 회원 통계 리스트
	 */
	function member_list() {
		log_message('debug', "@@@@ Statistic::member_list()");

		$yyyy = $this->input->get('yyyy', TRUE);
		$yyyy = !empty($yyyy) ? $yyyy : date("Y",time());

		$this->data['list'] = $this->model->select_member_list($user_id, $user_name, $start_dt, $end_dt, $current_page, $page_size);
		
		$this->load->view('statistic/member_list_v', $this->data);
	}

}
/* End of file statistic.php */
/* Location: ./application/controllers/statistic.php */